package com.youma.wt.mvpbaselib;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;


/**
**  类名：BaseFragment   创建目的： ""
**  作者：wangtong
**  时间:"2018/4/10 0010 17:48"
 * @object V Interface for Fragment
 * @object T Presenter for Fragment
*/
public abstract  class BaseFragment<V extends BaseViewInterface,T extends BasePrsenter>  extends Fragment{

    protected T mPresenter;
    protected BaseActivity mActivity;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view  = inflater.inflate(getLayoutId(),container,false);
        mPresenter = initPresenter();
        mPresenter.attchActivity((V)this);
        mActivity = (BaseActivity) getActivity();
        return view;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        mPresenter.dettchActivity();
    }

    public abstract int getLayoutId();
    public abstract T initPresenter();
}
